<?php
/**
 *
 * @package 
 * @since 1.0
 */
 
class SystemAction extends Action{
	/**
	 * ------------------------------
	 * 预处理
	 * ------------------------------
	 */
	function _initialize(){
		if( !isset($_SESSION['adm_name']) or !isset($_SESSION['isAdmin']) ) $this->redirect('Index/login');
	}
	/**
	 * ------------------------------
	 * 权限判断
	 * ------------------------------
	 */
	function pan_quan_ajax($data){  //ajax判断
		$pan=in_array($data,$_SESSION['admin_quan']);
        if($pan){
			return true;
		}else{
			return false;
		}
	}
	function pan_quan($data){ //php跳转判断
		$pan=in_array($data,$_SESSION['admin_quan']);
        if(!$pan){
			$this->error('您权限不足');
		}
	}
	/**
	 * ------------------------------
	 * 系统基本设置
	 * ------------------------------
	 */
	function sysset(){	
		$webid=$_GET['webid'];
		$this->assign('webid',$webid);
		$list = M('sysconfig')->where("webid=".$webid."")->order('id asc')->select();
		foreach($list as $k=>$v){
		   $data[$v['varname']] = $v['value'];
			if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
				$data[$v['varname']] = stripslashes($v['value']);
			}
		}
		$this->assign('pagetitle','系统基本参数设置');
		$this->assign($data);
		$this->display();
	}
	
	function setsys(){
		if (!M()->autoCheckToken($_POST)){
			$this->error('非法操作');
			die();
		}
		unset($_POST['__hash__']);
		$webid=$_POST['webid'];
		$list = M('sysconfig')->where("webid=".$webid."")->order('id asc')->select();
		//var_dump($_POST);exit;
		if(empty($list)){
			foreach ($_POST as $k=>$v) {
				if($k!='webid' && $k!='Button1'){
					$data['value'] = $v;
					$data['varname'] = $k;
					$data['webid'] = $webid;
					M('sysconfig')->add($data);
				}
			}
		}else{
			foreach ($_POST as $k=>$v) {
				$data['value'] = $v;
				M('sysconfig')->where("varname='".$k."' and webid=".$webid."")->save($data);
			}
		}
		$this->assign('jumpUrl', U('System/webs'));
		$this->success("已保存！");
	}
	

	/**
	 * ------------------------------
	 * 域名配置列表
	 * ------------------------------
	 */

	function webs(){
	
		import("@.ORG.Page");
		$count	= M('webs')->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		$list = M('webs')->order('id asc')->limit($Page->firstRow.','.$Page->listRows)
						     ->select();
	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '域名配置列表');
		$this->display();
	 }
	
	function editwebs(){
        $id = intval($_GET['id']);
		$menus = M('pz_menu')->where("mid=0")->order('xu asc,id desc')->select();
	    $this->assign('menus', $menus);
		if($id==''){
			$this->assign('pagetitle', '添加域名配置');
		}else{
			
			 $list = M('webs')->find($id);
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改域名配置');
		}
		$this->display('webs_edit');
	}
   
   function dowebs(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		
		$_POST['menuid']=$_POST['menuid'];
		$_POST['uid']=$_SESSION['uid'];
		if($_POST['id']){
				if( M('webs')->save($_POST) ){
					$this->assign('jumpUrl', U('System/webs'));
					$this->success('修改成功！');
				}else{
					$this->error('没有任何改动　或　修改失败！');
				}
		}else{
			$_POST['ctime']=time();
			$_POST['state']=1;
		      if( M('webs')->add($_POST) ){
					$this->assign('jumpUrl', U('System/webs'));
					$this->success('添加成功！');
			  }else{
					$this->error('添加失败！');
			  }
		}
	}


	
	/**
	 * ------------------------------
	 * 首页轮播配置
	 * ------------------------------
	 */

	function jiaodian(){
	
		import("@.ORG.Page");
		$count	= M('pz_jiaodian')->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		$list = M('pz_jiaodian')->order('xu asc,id desc')->limit($Page->firstRow.','.$Page->listRows)
						     ->select();
		foreach($list as $k=>$v){
			$webs=M('webs')->find($v['webid']);
			if(!empty($webs)){
				$list[$k]['wname']=$webs['name'];
			}else{
				$list[$k]['wname']="暂无";
			}
		}
	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '首页轮播配置列表');
		$this->display();
	 }
	
	function editjiaodian(){
        $id = intval($_GET['id']);
		if($id==''){
			$pan_admin=$this->pan_quan(2);//判断权限
			
			$this->assign('pagetitle', '添加首页轮播配置');
		}else{
			$pan_admin=$this->pan_quan(4);//判断权限
			
			 $list = M('pz_jiaodian')->find($id);
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改首页轮播配置');
		}
		$lang=M('pz_lang')->where("state=1")->order('xu asc,id asc')->select();
		foreach($lang as $k=>$v){
			$lang[$k]['menu_img_name']=$list["img_name".$v['id'].""];
			$lang[$k]['menu_img']=$list["img".$v['id'].""];
		}
	    $this->assign('lang_img_name', $lang);
	    $this->assign('lang_img', $lang);

		$webs=M('webs')->where("state=1")->order('id asc')->select();
	    $this->assign('webs', $webs);

		$this->display('jiaodian_edit');
	}
   
   function dojiaodian(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		
		$_POST['uid']=$_SESSION['uid'];
		if($_POST['id']){
				if( M('pz_jiaodian')->save($_POST) ){
					$this->assign('jumpUrl', U('System/jiaodian'));
					$this->success('修改成功！');
				}else{
					$this->error('没有任何改动　或　修改失败！');
				}
		}else{
		      if( M('pz_jiaodian')->add($_POST) ){
					$this->assign('jumpUrl', U('System/jiaodian'));
					$this->success('添加成功！');
			  }else{
					$this->error('添加失败！');
			  }
		}
	}
	
//	function xiajiaodian(){//下架
//	    $ids = $_POST['ids'];
//		$del = M('pz_jiaodian')->where("id IN ($ids) and state=1")->setField('state','2');//2为已下架
//        echo $del?'1':'0';
//	}
//	function shangjiaodian(){//上架
//	    $ids = $_POST['ids'];
//		$del = M('pz_jiaodian')->where("id IN ($ids) and state=2")->setField('state','1');//1为已上架
//        echo $del?'1':'0';
//	}
//	function deljiaodian(){//删除内容
//	    $ids = $_POST['ids'];
//		$del = M('pz_jiaodian')->where("id IN ($ids)")->setField('state','3');//3为已删除
//        echo $del?'1':'0';
//	}
//	function huijiaodian(){//恢复删除内容
//	    $ids = $_POST['ids'];
//		$del = M('pz_jiaodian')->where("id IN ($ids) and state=3")->setField('state','1');//1为发布
//        echo $del?'1':'0';
//	}
//	function noshenjiaodian(){//审核不通过
//	    $ids = $_POST['ids'];
//		$del = M('pz_jiaodian')->where("id IN ($ids) and state=1")->setField('state','0');//0为未发布
//        echo $del?'1':'0';
//	}
//	function shenjiaodian(){//审核通过
//	    $ids = $_POST['ids'];
//		$del = M('pz_jiaodian')->where("id IN ($ids) and state=0")->setField('state','1');//1为发布
//        echo $del?'1':'0';
//	}
	
	function xia_admin(){//下架
		$pan_admin=$this->pan_quan_ajax(8);//判断权限
		if(!$pan_admin){
			echo '0';exit;
		}
	    $ids = $_POST['ids'];
	    $sql_m = $_POST['sql_m'];
		$del = M("".$sql_m."")->where("id IN ($ids) and state=1")->setField('state','2');//2为已下架
        echo $del?'1':'0';
	}
	function shang_admin(){//上架
		$pan_admin=$this->pan_quan_ajax(6);//判断权限
		if(!$pan_admin){
			echo '0';exit;
		}
	    $ids = $_POST['ids'];
	    $sql_m = $_POST['sql_m'];
		$del = M("".$sql_m."")->where("id IN ($ids) and state=2")->setField('state','1');//1为已上架
        echo $del?'1':'0';
	}
	function del_admin(){//删除内容
		$pan_admin=$this->pan_quan_ajax(3);//判断权限
		if(!$pan_admin){
			echo '0';exit;
		}
	    $ids = $_POST['ids'];
	    $sql_m = $_POST['sql_m'];
		$del = M("".$sql_m."")->where("id IN ($ids)")->setField('state','3');//3为已删除
        echo $del?'1':'0';
	}
	function hui_admin(){//恢复删除内容
		$pan_admin=$this->pan_quan_ajax(12);//判断权限
		if(!$pan_admin){
			echo '0';exit;
		}
	    $ids = $_POST['ids'];
	    $sql_m = $_POST['sql_m'];
		$del = M("".$sql_m."")->where("id IN ($ids) and state=3")->setField('state','1');//1为发布
        echo $del?'1':'0';
	}
	function noshen_admin(){//审核不通过
		$pan_admin=$this->pan_quan_ajax(5);//判断权限
		if(!$pan_admin){
			echo '0';exit;
		}
	    $ids = $_POST['ids'];
	    $sql_m = $_POST['sql_m'];
		$del = M("".$sql_m."")->where("id IN ($ids) and state=1")->setField('state','0');//0为未发布
        echo $del?'1':'0';
	}
	function shen_admin(){//审核通过
		$pan_admin=$this->pan_quan_ajax(5);//判断权限
		if(!$pan_admin){
			echo '0';exit;
		}
	    $ids = $_POST['ids'];
	    $sql_m = $_POST['sql_m'];
		$del = M("".$sql_m."")->where("id IN ($ids) and state=0")->setField('state','1');//1为发布
        echo $del?'1':'0';
	}
	
	/**
	 * ------------------------------
	 * 权限配置
	 * ------------------------------
	 */

	function admin_quan(){
	
		import("@.ORG.Page");
		$count	= M('admin_quan')->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		$list = M('admin_quan')->order('xu asc,id asc')->limit($Page->firstRow.','.$Page->listRows)
						     ->select();
		foreach($list as $k=>$v){
			if($v['qid']==0){
				$list[$k]['qname']="顶级分类";
			}else{
				$qname=M('admin_quan')->find($v['qid']);
				$list[$k]['qname']=$qname['name'];
			}
		}
	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '权限配置列表');
	
		$this->display();
	 }
	
	function editadmin_quan(){
        $id = intval($_GET['id']);
		$quan_all=M('admin_quan')->where("state=1")->order('xu asc,id asc')->select();
	    $this->assign('quan_all', $quan_all);

		if($id==''){
		     $this->assign('pagetitle', '添加权限配置');
		}else{
			 $list = M('admin_quan')->find($id);
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改权限配置');
		}

		$this->display('admin_quan_edit');
	}
   
   function doadmin_quan(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		$_POST['state']=1;
		$_POST['uid']=$_SESSION['uid'];
		if($_POST['id']){
			$_POST['stime']=time();
			if( M('admin_quan')->save($_POST) ){
				$this->assign('jumpUrl', U('System/admin_quan'));
				$this->success('修改成功！');
			}else{
				$this->error('没有任何改动　或　修改失败！');
			}
		}else{
			$_POST['ctime']=time();
			if( M('admin_quan')->add($_POST) ){
				$this->assign('jumpUrl', U('System/admin_quan'));
				$this->success('添加成功！');
			}else{
				$this->error('添加失败！');
			}
		}
	}
	
	function deladmin_quan(){//删除内容
	    $ids = $_POST['ids'];
		$del = M('admin_quan')->where("id IN ($ids)")->setField('state','3');//3为已删除
        echo $del?'1':'0';
	}
	function huiadmin_quan(){//恢复删除内容
	    $ids = $_POST['ids'];
		$del = M('admin_quan')->where("id IN ($ids) and state=3")->setField('state','1');//1为发布
        echo $del?'1':'0';
	}
	/**
	 * ------------------------------
	 * 用户组配置
	 * ------------------------------
	 */

	function admin_group(){
	
		import("@.ORG.Page");
		$count	= M('admin_group')->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		$list = M('admin_group')->order('xu asc,id asc')->limit($Page->firstRow.','.$Page->listRows)
						     ->select();
	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '用户组配置列表');
	
		$this->display();
	 }
	
	function editadmin_group(){
        $id = intval($_GET['id']);
		$quans=M('admin_quan')->where("state=1 and qid=0")->order('xu asc,id asc')->select();
		foreach($quans as $k=>$v){
			$quans[$k]['erji']=M('admin_quan')->where("state=1 and qid=".$v['id']."")->order('xu asc,id asc')->select();
		}
	    $this->assign('quans', $quans);

		if($id==''){
		     $this->assign('pagetitle', '添加用户组配置');
		}else{
			 $list = M('admin_group')->find($id);
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改用户组配置');
		}

		$this->display('admin_group_edit');
	}
   
   function doadmin_group(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		$_POST['state']=1;
		$_POST['uid']=$_SESSION['uid'];
		if($_POST['id']){
			$_POST['stime']=time();
			if( M('admin_group')->save($_POST) ){
				$this->assign('jumpUrl', U('System/admin_group'));
				$this->success('修改成功！');
			}else{
				$this->error('没有任何改动　或　修改失败！');
			}
		}else{
			$_POST['ctime']=time();
			if( M('admin_group')->add($_POST) ){
				$this->assign('jumpUrl', U('System/admin_group'));
				$this->success('添加成功！');
			}else{
				$this->error('添加失败！');
			}
		}
	}
	
	function deladmin_group(){//删除内容
	    $ids = $_POST['ids'];
		$del = M('admin_group')->where("id IN ($ids)")->setField('state','3');//3为已删除
        echo $del?'1':'0';
	}
	function huiadmin_group(){//恢复删除内容
	    $ids = $_POST['ids'];
		$del = M('admin_group')->where("id IN ($ids) and state=3")->setField('state','1');//1为发布
        echo $del?'1':'0';
	}

	/**
	 * ------------------------------
	 * 语言配置
	 * ------------------------------
	 */
	function lang(){
	
		import("@.ORG.Page");
		$count	= M('pz_lang')->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		$list = M('pz_lang')->order('xu asc,id desc')->limit($Page->firstRow.','.$Page->listRows)
						     ->select();
		foreach($list as $k=>$v){
			if($v['state']==1){
				$list[$k]['state']="应用";
			}else{
				$list[$k]['state']="隐藏";
			}
		}
	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '语言配置列表');
	
		$this->display();
	 }
	
	function editlang(){
        $id = intval($_GET['id']);
		if($id==''){
		     $this->assign('pagetitle', '添加语言配置');
		}else{
			 $list = M('pz_lang')->find($id);
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改语言配置');
		}
		$this->display('lang_edit');
	}
   
   function dolang(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		if($_POST['state']===NULL){
			$_POST['state']=1;
		}
		
		$_POST['uid']=$_SESSION['uid'];
		if($_POST['id']){
				if( M('pz_lang')->save($_POST) ){
			  		$pzid=$_POST['id'];
					
					//分类配置 多语言字段
					$pzmodel_menu=M('pz_menu');
					$sql_menu="ALTER TABLE `kbjh_pz_menu` ADD `name".$pzid."` VARCHAR(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ";
					$res_menu = $pzmodel_menu->execute($sql_menu);
					
					//字典配置 多语言字段
					$pzmodel_zidian=M('pz_zidian');
					$sql_zidian="ALTER TABLE `kbjh_pz_zidian` ADD `name".$pzid."` VARCHAR(80) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ";
					$res_zidian = $pzmodel_zidian->execute($sql_zidian);
					
					//报导区域配置 多语言字段
					$pzmodel_area=M('pz_area');
					$sql_area="ALTER TABLE `kbjh_pz_area` ADD `name".$pzid."` VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `intro".$pzid."` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ";
					$res_area = $pzmodel_area->execute($sql_area);
					
					//商家区域配置 多语言字段
					$pzmodel_areas=M('pz_areas');
					$sql_areas="ALTER TABLE `kbjh_pz_areas` ADD `name".$pzid."` VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ";
					$res_areas = $pzmodel_areas->execute($sql_areas);
					
					//报导文章 多语言字段
					$pzmodel_article=M('article');
					$sql_article="ALTER TABLE `kbjh_article` ADD `name".$pzid."` VARCHAR(300) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `namesm".$pzid."` VARCHAR(800) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `zname".$pzid."` VARCHAR(600) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `content".$pzid."` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `areainf".$pzid."` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `remark".$pzid."` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `qa".$pzid."` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `service".$pzid."` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `service_out".$pzid."` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `service_pack".$pzid."` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ";
					$res_article = $pzmodel_article->execute($sql_article);
					
					//商家 多语言字段
					$pzmodel_shop=M('shop');
					$sql_shop="ALTER TABLE `kbjh_shop` ADD `name".$pzid."` VARCHAR(300) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `sintro".$pzid."` VARCHAR(900) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `intro".$pzid."` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `taoxi".$pzid."` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `qa".$pzid."` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `attention".$pzid."` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ";
					$res_shop = $pzmodel_shop->execute($sql_shop);
					
					//单页文章 多语言字段
					$pzmodel_page_art=M('page_art');
					$sql_page_art="ALTER TABLE `kbjh_page_art` ADD `name".$pzid."` VARCHAR(300) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `content".$pzid."` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ";
					$res_page_art = $pzmodel_page_art->execute($sql_page_art);

					//首页轮播图 多语言字段
					$pzmodel_pz_jiaodian=M('pz_jiaodian');
					$sql_pz_jiaodian="ALTER TABLE `kbjh_pz_jiaodian` ADD `img_name".$pzid."` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `img".$pzid."` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL";
					$res_pz_jiaodian = $pzmodel_pz_jiaodian->execute($sql_pz_jiaodian);
					
					//报导文章-相册 多语言字段
					$pzmodel_article_photo_files=M('article_photo_files');
					$sql_article_photo_files="ALTER TABLE `kbjh_article_photo_files` ADD `name".$pzid."` VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `url".$pzid."` VARCHAR(400) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `urlly".$pzid."` VARCHAR(400) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `intro".$pzid."` VARCHAR(300) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ";
					$res_article_photo_files = $pzmodel_article_photo_files->execute($sql_article_photo_files);
					
					//报导文章-相册-相片 多语言字段
					$pzmodel_article_photo=M('article_photo');
					$sql_article_photo="ALTER TABLE `kbjh_article_photo` ADD `name".$pzid."` VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `url".$pzid."` VARCHAR(400) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `urlly".$pzid."` VARCHAR(400) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ";
					$res_article_photo = $pzmodel_article_photo->execute($sql_article_photo);
					
					//报导文章-视频 多语言字段
					$pzmodel_article_video=M('article_video');
					$sql_article_video="ALTER TABLE `kbjh_article_video` ADD `name".$pzid."` VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `url".$pzid."` VARCHAR(400) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `urlly".$pzid."` VARCHAR(400) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `intro".$pzid."` VARCHAR(500) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ";
					$res_article_video = $pzmodel_article_video->execute($sql_article_video);
					
					//商家-top产品 多语言字段
					$pzmodel_shop_topphoto=M('shop_topphoto');
					$sql_shop_topphoto="ALTER TABLE `kbjh_shop_topphoto` ADD `name".$pzid."` VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `url".$pzid."` VARCHAR(400) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `urlly".$pzid."` VARCHAR(400) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `intro".$pzid."` VARCHAR(200) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ";
					$res_shop_topphoto = $pzmodel_shop_topphoto->execute($sql_shop_topphoto);

					//商家-相册 多语言字段
					$pzmodel_shop_photo_files=M('shop_photo_files');
					$sql_shop_photo_files="ALTER TABLE `kbjh_shop_photo_files` ADD `name".$pzid."` VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `url".$pzid."` VARCHAR(400) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `urlly".$pzid."` VARCHAR(400) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `intro".$pzid."` VARCHAR(300) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ";
					$res_shop_photo_files = $pzmodel_shop_photo_files->execute($sql_shop_photo_files);
					
					//商家-相册-相片 多语言字段
					$pzmodel_shop_photo=M('shop_photo');
					$sql_shop_photo="ALTER TABLE `kbjh_shop_photo` ADD `name".$pzid."` VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `url".$pzid."` VARCHAR(400) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `urlly".$pzid."` VARCHAR(400) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ";
					$res_shop_photo = $pzmodel_shop_photo->execute($sql_shop_photo);
					
					//商家-视频 多语言字段
					$pzmodel_shop_video=M('shop_video');
					$sql_shop_video="ALTER TABLE `kbjh_shop_video` ADD `name".$pzid."` VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `url".$pzid."` VARCHAR(400) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `urlly".$pzid."` VARCHAR(400) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `intro".$pzid."` VARCHAR(500) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ";
					$res_shop_video = $pzmodel_shop_video->execute($sql_shop_video);
					
					//商家-商店资料 多语言字段
					$pzmodel_shop_info=M('shop_info');
					$sql_shop_info="ALTER TABLE `kbjh_shop_info` ADD `name".$pzid."` VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `openday".$pzid."` VARCHAR(80) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `opentime".$pzid."` VARCHAR(80) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `address".$pzid."` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `tel".$pzid."` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `fax".$pzid."` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `email".$pzid."` VARCHAR(110) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ";
					$res_shop_info = $pzmodel_shop_info->execute($sql_shop_info);
					
					//报导文章-主图区图片 多语言字段
					$pzmodel_article_zhutu=M('article');
					$sql_article_zhutu="ALTER TABLE `kbjh_article` ADD `zhutu".$pzid."` VARCHAR(150) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `zhutuly".$pzid."` VARCHAR(400) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ";
					$res_article_zhutu = $pzmodel_article_zhutu->execute($sql_article_zhutu);

					//分类配置-排序 多语言字段
					$pzmodel_pz_menu_xu=M('pz_menu');
					$sql_pz_menu_xu="ALTER TABLE `kbjh_pz_menu` ADD `xu".$pzid."` int(11) NOT NULL ";
					$res_pz_menu_xu = $pzmodel_pz_menu_xu->execute($sql_pz_menu_xu);
					
					//二级 分类 图 多语言字段
					$pzmodel_menu_img=M('menu_img');
					$sql_menu_img="ALTER TABLE `kbjh_menu_img` ADD `name".$pzid."` VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `img_name".$pzid."` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `img".$pzid."` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL";
					$res_menu_img = $pzmodel_menu_img->execute($sql_menu_img);
										
					//其他 广告位 多语言字段
					$pzmodel_gg_wz=M('gg_wz');
					$sql_gg_wz="ALTER TABLE `kbjh_gg_wz` ADD `name".$pzid."` VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ";
					$res_gg_wz = $pzmodel_gg_wz->execute($sql_gg_wz);
					
					//其他 广告位 轮播图 多语言字段
					$pzmodel_gg_lbimg=M('gg_lbimg');
					$sql_gg_lbimg="ALTER TABLE `kbjh_gg_lbimg` ADD `name".$pzid."` VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `img_name".$pzid."` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `img".$pzid."` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL";
					$res_gg_lbimg = $pzmodel_gg_lbimg->execute($sql_gg_lbimg);

					//投票 主题 多语言字段
					$pzmodel_tou_zhuti=M('tou');
					$sql_tou_zhuti="ALTER TABLE `kbjh_tou` ADD `name".$pzid."` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `content".$pzid."` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL";
					$res_tou_zhuti = $pzmodel_tou_zhuti->execute($sql_tou_zhuti);

					//投票 事项 多语言字段
					$pzmodel_tou_shi=M('tou_shi');
					$sql_tou_shi="ALTER TABLE `kbjh_tou_shi` ADD `name".$pzid."` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `img".$pzid."` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `jianjie".$pzid."` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL";
					$res_tou_shi = $pzmodel_tou_shi->execute($sql_tou_shi);

					//投票 选项 多语言字段
					$pzmodel_tou_xuan=M('tou_xuan');
					$sql_tou_xuan="ALTER TABLE `kbjh_tou_xuan` ADD `name".$pzid."` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL";
					$res_tou_xuan = $pzmodel_tou_xuan->execute($sql_tou_xuan);

					$this->assign('jumpUrl', U('System/lang'));
					$this->success('修改成功！');
				}else{
					$this->error('没有任何改动　或　修改失败！');
				}
		}else{
			  
			  $result=M('pz_lang')->add($_POST);
		      if( $result ){
			  		$pzid=$result;
					
					//分类配置 多语言字段
					$pzmodel_menu=M('pz_menu');
					$sql_menu="ALTER TABLE `kbjh_pz_menu` ADD `name".$pzid."` VARCHAR(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ";
					$res_menu = $pzmodel_menu->execute($sql_menu);
					
					//字典配置 多语言字段
					$pzmodel_zidian=M('pz_zidian');
					$sql_zidian="ALTER TABLE `kbjh_pz_zidian` ADD `name".$pzid."` VARCHAR(80) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ";
					$res_zidian = $pzmodel_zidian->execute($sql_zidian);
					
					//报导区域配置 多语言字段
					$pzmodel_area=M('pz_area');
					$sql_area="ALTER TABLE `kbjh_pz_area` ADD `name".$pzid."` VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `intro".$pzid."` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ";
					$res_area = $pzmodel_area->execute($sql_area);
					
					//商家区域配置 多语言字段
					$pzmodel_areas=M('pz_areas');
					$sql_areas="ALTER TABLE `kbjh_pz_areas` ADD `name".$pzid."` VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ";
					$res_areas = $pzmodel_areas->execute($sql_areas);
					
					//报导文章 多语言字段
					$pzmodel_article=M('article');
					$sql_article="ALTER TABLE `kbjh_article` ADD `name".$pzid."` VARCHAR(300) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `namesm".$pzid."` VARCHAR(800) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `zname".$pzid."` VARCHAR(600) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `content".$pzid."` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `areainf".$pzid."` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `remark".$pzid."` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `qa".$pzid."` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `service".$pzid."` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `service_out".$pzid."` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `service_pack".$pzid."` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ";
					$res_article = $pzmodel_article->execute($sql_article);
					
					//商家 多语言字段
					$pzmodel_shop=M('shop');
					$sql_shop="ALTER TABLE `kbjh_shop` ADD `name".$pzid."` VARCHAR(300) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `sintro".$pzid."` VARCHAR(900) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `intro".$pzid."` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `taoxi".$pzid."` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `qa".$pzid."` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `attention".$pzid."` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ";
					$res_shop = $pzmodel_shop->execute($sql_shop);
					
					//单页文章 多语言字段
					$pzmodel_page_art=M('page_art');
					$sql_page_art="ALTER TABLE `kbjh_page_art` ADD `name".$pzid."` VARCHAR(300) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `content".$pzid."` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ";
					$res_page_art = $pzmodel_page_art->execute($sql_page_art);
					
					//首页轮播图 多语言字段
					$pzmodel_pz_jiaodian=M('pz_jiaodian');
					$sql_pz_jiaodian="ALTER TABLE `kbjh_pz_jiaodian` ADD `img_name".$pzid."` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `img".$pzid."` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL";
					$res_pz_jiaodian = $pzmodel_pz_jiaodian->execute($sql_pz_jiaodian);
					
					//报导文章-相册 多语言字段
					$pzmodel_article_photo_files=M('article_photo_files');
					$sql_article_photo_files="ALTER TABLE `kbjh_article_photo_files` ADD `name".$pzid."` VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `url".$pzid."` VARCHAR(400) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `urlly".$pzid."` VARCHAR(400) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `intro".$pzid."` VARCHAR(300) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ";
					$res_article_photo_files = $pzmodel_article_photo_files->execute($sql_article_photo_files);
					
					//报导文章-相册-相片 多语言字段
					$pzmodel_article_photo=M('article_photo');
					$sql_article_photo="ALTER TABLE `kbjh_article_photo` ADD `name".$pzid."` VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `url".$pzid."` VARCHAR(400) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `urlly".$pzid."` VARCHAR(400) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ";
					$res_article_photo = $pzmodel_article_photo->execute($sql_article_photo);
					
					//报导文章-视频 多语言字段
					$pzmodel_article_video=M('article_video');
					$sql_article_video="ALTER TABLE `kbjh_article_video` ADD `name".$pzid."` VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `url".$pzid."` VARCHAR(400) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `urlly".$pzid."` VARCHAR(400) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `intro".$pzid."` VARCHAR(500) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ";
					$res_article_video = $pzmodel_article_video->execute($sql_article_video);
					
					//商家-top产品 多语言字段
					$pzmodel_shop_topphoto=M('shop_topphoto');
					$sql_shop_topphoto="ALTER TABLE `kbjh_shop_topphoto` ADD `name".$pzid."` VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `url".$pzid."` VARCHAR(400) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `urlly".$pzid."` VARCHAR(400) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `intro".$pzid."` VARCHAR(200) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ";
					$res_shop_topphoto = $pzmodel_shop_topphoto->execute($sql_shop_topphoto);

					//商家-相册 多语言字段
					$pzmodel_shop_photo_files=M('shop_photo_files');
					$sql_shop_photo_files="ALTER TABLE `kbjh_shop_photo_files` ADD `name".$pzid."` VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `url".$pzid."` VARCHAR(400) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `urlly".$pzid."` VARCHAR(400) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `intro".$pzid."` VARCHAR(300) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ";
					$res_shop_photo_files = $pzmodel_shop_photo_files->execute($sql_shop_photo_files);
					
					//商家-相册-相片 多语言字段
					$pzmodel_shop_photo=M('shop_photo');
					$sql_shop_photo="ALTER TABLE `kbjh_shop_photo` ADD `name".$pzid."` VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `url".$pzid."` VARCHAR(400) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `urlly".$pzid."` VARCHAR(400) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ";
					$res_shop_photo = $pzmodel_shop_photo->execute($sql_shop_photo);
					
					//商家-视频 多语言字段
					$pzmodel_shop_video=M('shop_video');
					$sql_shop_video="ALTER TABLE `kbjh_shop_video` ADD `name".$pzid."` VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `url".$pzid."` VARCHAR(400) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `urlly".$pzid."` VARCHAR(400) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `intro".$pzid."` VARCHAR(500) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ";
					$res_shop_video = $pzmodel_shop_video->execute($sql_shop_video);
					
					//商家-商店资料 多语言字段
					$pzmodel_shop_info=M('shop_info');
					$sql_shop_info="ALTER TABLE `kbjh_shop_info` ADD `name".$pzid."` VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `openday".$pzid."` VARCHAR(80) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `opentime".$pzid."` VARCHAR(80) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `address".$pzid."` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `tel".$pzid."` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `fax".$pzid."` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `email".$pzid."` VARCHAR(110) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ";
					$res_shop_info = $pzmodel_shop_info->execute($sql_shop_info);

					//报导文章-主图区图片 多语言字段
					$pzmodel_article_zhutu=M('article');
					$sql_article_zhutu="ALTER TABLE `kbjh_article` ADD `zhutu".$pzid."` VARCHAR(150) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `zhutuly".$pzid."` VARCHAR(400) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ";
					$res_article_zhutu = $pzmodel_article_zhutu->execute($sql_article_zhutu);

					//分类配置-排序 多语言字段
					$pzmodel_pz_menu_xu=M('pz_menu');
					$sql_pz_menu_xu="ALTER TABLE `kbjh_pz_menu` ADD `xu".$pzid."` int(11) NOT NULL ";
					$res_pz_menu_xu = $pzmodel_pz_menu_xu->execute($sql_pz_menu_xu);
					
					//二级 分类 图 多语言字段
					$pzmodel_menu_img=M('menu_img');
					$sql_menu_img="ALTER TABLE `kbjh_menu_img` ADD `name".$pzid."` VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `img_name".$pzid."` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `img".$pzid."` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL";
					$res_menu_img = $pzmodel_menu_img->execute($sql_menu_img);
					

					//投票 主题 多语言字段
					$pzmodel_tou_zhuti=M('tou');
					$sql_tou_zhuti="ALTER TABLE `kbjh_tou` ADD `name".$pzid."` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `content".$pzid."` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL";
					$res_tou_zhuti = $pzmodel_tou_zhuti->execute($sql_tou_zhuti);

					//投票 事项 多语言字段
					$pzmodel_tou_shi=M('tou_shi');
					$sql_tou_shi="ALTER TABLE `kbjh_tou_shi` ADD `name".$pzid."` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `img".$pzid."` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , ADD `jianjie".$pzid."` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL";
					$res_tou_shi = $pzmodel_tou_shi->execute($sql_tou_shi);

					//投票 选项 多语言字段
					$pzmodel_tou_xuan=M('tou_xuan');
					$sql_tou_xuan="ALTER TABLE `kbjh_tou_xuan` ADD `name".$pzid."` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL";
					$res_tou_xuan = $pzmodel_tou_xuan->execute($sql_tou_xuan);

					$this->assign('jumpUrl', U('System/lang'));
					$this->success('添加成功！');
			  }else{
					$this->error('添加失败！');
			  }
		}
	}
	
	function dellang(){
	    $ids = $_POST['ids'];
		$del = M('pz_lang')->where("id IN ($ids)")->setField('state','0');
        echo $del?'1':'0';
	}
	/**
	 * ------------------------------
	 * 旅游区域配置
	 * ------------------------------
	 */
	function area(){
	
		import("@.ORG.Page");
		$count	= M('pz_area')->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		$list = M('pz_area')->order('xu asc,id desc')->limit($Page->firstRow.','.$Page->listRows)
						     ->select();
	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '区域配置列表');
	
		$this->display();
	 }
	
	function editarea(){
        $id = intval($_GET['id']);
		if($id==''){
		     $this->assign('pagetitle', '添加区域配置');
		}else{
			 $list = M('pz_area')->find($id);
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改区域配置');
		}
		$lang=M('pz_lang')->where("state=1")->order('xu asc,id asc')->select();
		foreach($lang as $k=>$v){
			$lang[$k]['menu_name']=$list["name".$v['id'].""];
			$lang[$k]['menu_intro']=$list["intro".$v['id'].""];
		}
	    $this->assign('lang', $lang);
	    $this->assign('lang_intro', $lang);
		$this->display('area_edit');
	}
   
   function doarea(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		
		
		$_POST['uid']=$_SESSION['uid'];
		$_POST['state']=1;
		if($_POST['id']){
				if( M('pz_area')->save($_POST) ){
					$this->assign('jumpUrl', U('System/area'));
					$this->success('修改成功！');
				}else{
					$this->error('没有任何改动　或　修改失败！');
				}
		}else{
		      if( M('pz_area')->add($_POST) ){
					$this->assign('jumpUrl', U('System/area'));
					$this->success('添加成功！');
			  }else{
					$this->error('添加失败！');
			  }
		}
	}
	
	function delarea(){
	    $ids = $_POST['ids'];
		$del = M('pz_area')->where("id IN ($ids)")->setField('state','3');
        echo $del?'1':'0';
	}
	/**
	 * ------------------------------
	 * 广告版面配置
	 * ------------------------------
	 */
	function adway(){
	
		import("@.ORG.Page");
		$count	= M('pz_adway')->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		$list = M('pz_adway')->order('xu asc,id desc')->limit($Page->firstRow.','.$Page->listRows)
						     ->select();
	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '广告版面配置列表');
	
		$this->display();
	 }
	
	function editadway(){
        $id = intval($_GET['id']);
		if($id==''){
		     $this->assign('pagetitle', '添加广告版面配置');
		}else{
			 $list = M('pz_adway')->find($id);
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改广告版面配置');
		}
		$this->display('adway_edit');
	}
   
   function doadway(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		
		
		$_POST['uid']=$_SESSION['uid'];
		if($_POST['id']){
				if( M('pz_adway')->save($_POST) ){
					$this->assign('jumpUrl', U('System/adway'));
					$this->success('修改成功！');
				}else{
					$this->error('没有任何改动　或　修改失败！');
				}
		}else{
		      if( M('pz_adway')->add($_POST) ){
					$this->assign('jumpUrl', U('System/adway'));
					$this->success('添加成功！');
			  }else{
					$this->error('添加失败！');
			  }
		}
	}
	
	function deladway(){
	    $ids = $_POST['ids'];
		$del = M('pz_adway')->where("id IN ($ids)")->setField('state','3');
        echo $del?'1':'0';
	}
	/**
	 * ------------------------------
	 * 特推主页配置
	 * ------------------------------
	 */
	function main(){
	
		import("@.ORG.Page");
		$count	= M('pz_main')->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		$list = M('pz_main')->order('xu asc,id desc')->limit($Page->firstRow.','.$Page->listRows)
						     ->select();
	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '特推主页配置列表');
	
		$this->display();
	 }
	
	function editmain(){
        $id = intval($_GET['id']);
		if($id==''){
		     $this->assign('pagetitle', '添加特推主页配置');
		}else{
			 $list = M('pz_main')->find($id);
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改特推主页配置');
		}
		$this->display('main_edit');
	}
   
   function domain(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		
		
		$_POST['uid']=$_SESSION['uid'];
		if($_POST['id']){
				if( M('pz_main')->save($_POST) ){
					$this->assign('jumpUrl', U('System/main'));
					$this->success('修改成功！');
				}else{
					$this->error('没有任何改动　或　修改失败！');
				}
		}else{
		      if( M('pz_main')->add($_POST) ){
					$this->assign('jumpUrl', U('System/main'));
					$this->success('添加成功！');
			  }else{
					$this->error('添加失败！');
			  }
		}
	}
	
	function delmain(){
	    $ids = $_POST['ids'];
		$del = M('pz_main')->where("id IN ($ids)")->setField('state','3');
        echo $del?'1':'0';
	}
	/**
	 * ------------------------------
	 * 分类配置
	 * ------------------------------
	 */
	function menu(){
	
		import("@.ORG.Page");
		$count	= M('pz_menu')->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		$list = M('pz_menu')->order('xu asc,id asc')->limit($Page->firstRow.','.$Page->listRows)
						     ->select();
		foreach($list as $k=>$v){
			if($v['mid']==0){
				$list[$k]['mname']="顶级分类";
			}else{
				$mname=M('pz_menu')->find($v['mid']);
				$list[$k]['mname']=$mname['name'];
			}
			$list[$k]['lang_xus']=M('pz_lang')->where("state=1")->order('xu asc,id asc')->select();
			foreach($list[$k]['lang_xus'] as $kk=>$vv){
				$list[$k]['lang_xus'][$kk]['menu_xu']=$v["xu".$vv['id'].""];
			}
//			$webs=M('webs')->find($v['webid']);
//			if(!empty($webs)){
//				$list[$k]['wname']=$webs['name'];
//			}else{
//				$list[$k]['wname']="暂无";
//			}
		}
		
		$lang=M('pz_lang')->where("state=1")->order('xu asc,id asc')->select();
	    $this->assign('lang_xu', $lang);

	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '分类配置列表');
	
		$this->display();
	 }
	
	function editmenu(){
        $id = intval($_GET['id']);
		$topmenu=M('pz_menu')->where("mid=0")->order('xu asc,id asc')->select();
	    $this->assign('topmenu', $topmenu);
		if($id==''){
		     $this->assign('pagetitle', '添加分类配置');
		}else{
			 $list = M('pz_menu')->find($id);
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改分类配置');
		}
		$lang=M('pz_lang')->where("state=1")->order('xu asc,id asc')->select();
		foreach($lang as $k=>$v){
			$lang[$k]['menu_name']=$list["name".$v['id'].""];
			$lang[$k]['menu_xu']=$list["xu".$v['id'].""];
		}
	    $this->assign('lang', $lang);
	    $this->assign('lang_xu', $lang);
//		$webs=M('webs')->where("state=1")->order('id asc')->select();
//	    $this->assign('webs', $webs);
		
		//var_dump($list);
		$this->display('menu_edit');
	}
   
   function domenu(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		
		
		$_POST['state']=1;
		$_POST['uid']=$_SESSION['uid'];
		if($_POST['id']){
				if( M('pz_menu')->save($_POST) ){
					$this->assign('jumpUrl', U('System/menu'));
					$this->success('修改成功！');
				}else{
					$this->error('没有任何改动　或　修改失败！');
				}
		}else{
		      if( M('pz_menu')->add($_POST) ){
					$this->assign('jumpUrl', U('System/menu'));
					$this->success('添加成功！');
			  }else{
					$this->error('添加失败！');
			  }
		}
	}
	
	function delmenu(){
	    $ids = $_POST['ids'];
		$del = M('pz_menu')->where("id IN ($ids)")->setField('state','3');
        echo $del?'1':'0';
	}
	/**
	 * ------------------------------
	 * 字典配置
	 * ------------------------------
	 */
	function zidian(){
	
		import("@.ORG.Page");
		$count	= M('pz_zidian')->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		$list = M('pz_zidian')->order('xu asc,id asc')->limit($Page->firstRow.','.$Page->listRows)
						     ->select();
//		foreach($list as $k=>$v){
//			if($v['mid']==0){
//				$list[$k]['mname']="顶级分类";
//			}else{
//				$mname=M('pz_zidian')->find($v['mid']);
//				$list[$k]['mname']=$mname['name'];
//			}
//		}
	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '字典配置列表');
	
		$this->display();
	 }
	
	function editzidian(){
        $id = intval($_GET['id']);
		$topzidian=M('pz_zidian')->where("mid=0")->order('xu asc,id asc')->select();
	    $this->assign('topzidian', $topzidian);
		if($id==''){
		     $this->assign('pagetitle', '添加字典配置');
		}else{
			 $list = M('pz_zidian')->find($id);
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改字典配置');
		}
		$lang=M('pz_lang')->where("state=1")->order('xu asc,id asc')->select();
		foreach($lang as $k=>$v){
			$lang[$k]['zidian_name']=$list["name".$v['id'].""];
		}
	    $this->assign('lang', $lang);
		//var_dump($list);
		$this->display('zidian_edit');
	}
   
   function dozidian(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		
		
		$_POST['uid']=$_SESSION['uid'];
		if($_POST['id']){
				if( M('pz_zidian')->save($_POST) ){
					$this->assign('jumpUrl', U('System/zidian'));
					$this->success('修改成功！');
				}else{
					$this->error('没有任何改动　或　修改失败！');
				}
		}else{
		      if( M('pz_zidian')->add($_POST) ){
					$this->assign('jumpUrl', U('System/zidian'));
					$this->success('添加成功！');
			  }else{
					$this->error('添加失败！');
			  }
		}
	}
	
	function delzidian(){
	    $ids = $_POST['ids'];
		$del = M('pz_zidian')->where("id IN ($ids)")->setField('state','3');
        echo $del?'1':'0';
	}
 


	
	/**
	 * ------------------------------
	 * 首页 视频
	 * ------------------------------
	 */

	function sy_shipin(){
	
		import("@.ORG.Page");
		$count	= M('sy_shipin')->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		$list = M('sy_shipin')->order('xu asc,id desc')->limit($Page->firstRow.','.$Page->listRows)
						     ->select();
		foreach($list as $k=>$v){
			$webs=M('webs')->find($v['webid']);
			if(!empty($webs)){
				$list[$k]['wname']=$webs['name'];
			}else{
				$list[$k]['wname']="暂无";
			}
		}
	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '首页视频列表');
		$this->display();
	 }
	
	function editsy_shipin(){
        $id = intval($_GET['id']);
		if($id==''){
			$pan_admin=$this->pan_quan(2);//判断权限
			
			$this->assign('pagetitle', '添加首页视频');
		}else{
			$pan_admin=$this->pan_quan(4);//判断权限
			
			 $list = M('sy_shipin')->find($id);
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改首页视频');
		}
		$lang=M('pz_lang')->where("state=1")->order('xu asc,id asc')->select();
		foreach($lang as $k=>$v){
			$lang[$k]['menu_img_name']=$list["img_name".$v['id'].""];
			$lang[$k]['menu_img']=$list["img".$v['id'].""];
		}
	    $this->assign('lang_img_name', $lang);
	    $this->assign('lang_img', $lang);

		$webs=M('webs')->where("state=1")->order('id asc')->select();
	    $this->assign('webs', $webs);

		$this->display('sy_shipin_edit');
	}
   
   function dosy_shipin(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		
		$_POST['uid']=$_SESSION['uid'];
		if($_POST['id']){
				if( M('sy_shipin')->save($_POST) ){
					$this->assign('jumpUrl', U('System/sy_shipin'));
					$this->success('修改成功！');
				}else{
					$this->error('没有任何改动　或　修改失败！');
				}
		}else{
		      if( M('sy_shipin')->add($_POST) ){
					$this->assign('jumpUrl', U('System/sy_shipin'));
					$this->success('添加成功！');
			  }else{
					$this->error('添加失败！');
			  }
		}
	}

	/**
	 * ------------------------------
	 * 首页 节目单
	 * ------------------------------
	 */

	function sy_jiemudan(){
	
		import("@.ORG.Page");
		$count	= M('sy_jiemudan')->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		$list = M('sy_jiemudan')->order('xu asc,id desc')->limit($Page->firstRow.','.$Page->listRows)
						     ->select();
		foreach($list as $k=>$v){
			$webs=M('webs')->find($v['webid']);
			if(!empty($webs)){
				$list[$k]['wname']=$webs['name'];
			}else{
				$list[$k]['wname']="暂无";
			}
		}
	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '首页节目单列表');
		$this->display();
	 }
	
	function editsy_jiemudan(){
        $id = intval($_GET['id']);
		if($id==''){
			$pan_admin=$this->pan_quan(2);//判断权限
			
			$this->assign('pagetitle', '添加首页节目单');
		}else{
			$pan_admin=$this->pan_quan(4);//判断权限
			
			 $list = M('sy_jiemudan')->find($id);
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改首页节目单');
		}
		$lang=M('pz_lang')->where("state=1")->order('xu asc,id asc')->select();
		foreach($lang as $k=>$v){
			$lang[$k]['menu_img_name']=$list["img_name".$v['id'].""];
			$lang[$k]['menu_img']=$list["img".$v['id'].""];
		}
	    $this->assign('lang_img_name', $lang);
	    $this->assign('lang_img', $lang);

		$webs=M('webs')->where("state=1")->order('id asc')->select();
	    $this->assign('webs', $webs);

		$this->display('sy_jiemudan_edit');
	}
   
   function dosy_jiemudan(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		
		$_POST['uid']=$_SESSION['uid'];
		if($_POST['id']){
				if( M('sy_jiemudan')->save($_POST) ){
					$this->assign('jumpUrl', U('System/sy_jiemudan'));
					$this->success('修改成功！');
				}else{
					$this->error('没有任何改动　或　修改失败！');
				}
		}else{
		      if( M('sy_jiemudan')->add($_POST) ){
					$this->assign('jumpUrl', U('System/sy_jiemudan'));
					$this->success('添加成功！');
			  }else{
					$this->error('添加失败！');
			  }
		}
	}

	/**
	 * ------------------------------
	 * 首页 精彩推荐
	 * ------------------------------
	 */

	function sy_tuijian(){
	
		import("@.ORG.Page");
		$count	= M('sy_tuijian')->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		$list = M('sy_tuijian')->order('xu asc,id desc')->limit($Page->firstRow.','.$Page->listRows)
						     ->select();
		foreach($list as $k=>$v){
			$webs=M('webs')->find($v['webid']);
			if(!empty($webs)){
				$list[$k]['wname']=$webs['name'];
			}else{
				$list[$k]['wname']="暂无";
			}
		}
	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '首页精彩推荐列表');
		$this->display();
	 }
	
	function editsy_tuijian(){
        $id = intval($_GET['id']);
		if($id==''){
			$pan_admin=$this->pan_quan(2);//判断权限
			
			$this->assign('pagetitle', '添加首页精彩推荐');
		}else{
			$pan_admin=$this->pan_quan(4);//判断权限
			
			 $list = M('sy_tuijian')->find($id);
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改首页精彩推荐');
		}
		$lang=M('pz_lang')->where("state=1")->order('xu asc,id asc')->select();
		foreach($lang as $k=>$v){
			$lang[$k]['menu_img_name']=$list["img_name".$v['id'].""];
			$lang[$k]['menu_img']=$list["img".$v['id'].""];
		}
	    $this->assign('lang_img_name', $lang);
	    $this->assign('lang_img', $lang);

		$webs=M('webs')->where("state=1")->order('id asc')->select();
	    $this->assign('webs', $webs);

		$this->display('sy_tuijian_edit');
	}
   
   function dosy_tuijian(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		
		$_POST['uid']=$_SESSION['uid'];
		if($_POST['id']){
				if( M('sy_tuijian')->save($_POST) ){
					$this->assign('jumpUrl', U('System/sy_tuijian'));
					$this->success('修改成功！');
				}else{
					$this->error('没有任何改动　或　修改失败！');
				}
		}else{
		      if( M('sy_tuijian')->add($_POST) ){
					$this->assign('jumpUrl', U('System/sy_tuijian'));
					$this->success('添加成功！');
			  }else{
					$this->error('添加失败！');
			  }
		}
	}

	/**
	 * ------------------------------
	 * 二级 分类 图片 配置
	 * ------------------------------
	 */

	function menu_img(){
	
		import("@.ORG.Page");
		$count	= M('menu_img')->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		$list = M('menu_img')->order('mid asc,xu asc,id desc')->limit($Page->firstRow.','.$Page->listRows)
						     ->select();
		foreach($list as $k=>$v){
			$menuname=M('pz_menu')->find($v['mid']);
			$list[$k]['menuname']=$menuname['name'];
		}
	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '分类广告图片列表');
		$this->display();
	 }
	
	function editmenu_img(){
        $id = intval($_GET['id']);
		if($id==''){
			$pan_admin=$this->pan_quan(2);//判断权限
			
			$this->assign('pagetitle', '添加分类广告图片');
		}else{
			$pan_admin=$this->pan_quan(4);//判断权限
			
			 $list = M('menu_img')->find($id);
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改分类广告图片');
		}
		$menu=M('pz_menu')->where("state=1")->order('xu asc,id asc')->select();
	    $this->assign('menu', $menu);
		$lang=M('pz_lang')->where("state=1")->order('xu asc,id asc')->select();
		foreach($lang as $k=>$v){
			$lang[$k]['menu_name']=$list["name".$v['id'].""];
			$lang[$k]['menu_img_name']=$list["img_name".$v['id'].""];
			$lang[$k]['menu_img']=$list["img".$v['id'].""];
		}
	    $this->assign('lang_name', $lang);
	    $this->assign('lang_img_name', $lang);
	    $this->assign('lang_img', $lang);

		$this->display('menu_img_edit');
	}
   
   function domenu_img(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		
		$_POST['uid']=$_SESSION['uid'];
		if($_POST['id']){
			$_POST['stime']=time();
				if( M('menu_img')->save($_POST) ){
					$this->assign('jumpUrl', U('System/menu_img'));
					$this->success('修改成功！');
				}else{
					$this->error('没有任何改动　或　修改失败！');
				}
		}else{
			$_POST['ctime']=time();
		      if( M('menu_img')->add($_POST) ){
					$this->assign('jumpUrl', U('System/menu_img'));
					$this->success('添加成功！');
			  }else{
					$this->error('添加失败！');
			  }
		}
	}
	/**
	 * ------------------------------
	 * 其他 广告位 配置
	 * ------------------------------
	 */

	function gg_wz(){
	
		import("@.ORG.Page");
		$count	= M('gg_wz')->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		$list = M('gg_wz')->order('xu asc,id desc')->limit($Page->firstRow.','.$Page->listRows)
						     ->select();
	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '其他广告位列表');
		$this->display();
	 }
	
	function editgg_wz(){
        $id = intval($_GET['id']);
		if($id==''){
			$pan_admin=$this->pan_quan(2);//判断权限
			
			$this->assign('pagetitle', '添加其他广告位');
		}else{
			$pan_admin=$this->pan_quan(4);//判断权限
			
			 $list = M('gg_wz')->find($id);
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改其他广告位');
		}
		$lang=M('pz_lang')->where("state=1")->order('xu asc,id asc')->select();
		foreach($lang as $k=>$v){
			$lang[$k]['menu_img_name']=$list["img_name".$v['id'].""];
			$lang[$k]['menu_img']=$list["img".$v['id'].""];
		}
	    $this->assign('lang_img_name', $lang);
	    $this->assign('lang_img', $lang);
		$this->display('gg_wz_edit');
	}
   
   function dogg_wz(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		
		$_POST['uid']=$_SESSION['uid'];
		if($_POST['id']){
			$_POST['stime']=time();
				if( M('gg_wz')->save($_POST) ){
					$this->assign('jumpUrl', U('System/gg_wz'));
					$this->success('修改成功！');
				}else{
					$this->error('没有任何改动　或　修改失败！');
				}
		}else{
			$_POST['ctime']=time();
		      if( M('gg_wz')->add($_POST) ){
					$this->assign('jumpUrl', U('System/gg_wz'));
					$this->success('添加成功！');
			  }else{
					$this->error('添加失败！');
			  }
		}
	}
	/**
	 * ------------------------------
	 * 其他 广告位 轮播图片 配置
	 * ------------------------------
	 */

	function gg_lbimg(){
	
		import("@.ORG.Page");
		$count	= M('gg_lbimg')->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		$list = M('gg_lbimg')->order('wid asc,xu asc,id desc')->limit($Page->firstRow.','.$Page->listRows)
						     ->select();
		foreach($list as $k=>$v){
			$wzname=M('gg_wz')->find($v['wid']);
			$list[$k]['wzname']=$wzname['name'];
			
			$webs=M('webs')->find($v['webid']);
			if(!empty($webs)){
				$list[$k]['wname']=$webs['name'];
			}else{
				$list[$k]['wname']="暂无";
			}
		}
	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '其他广告位图片列表');
		$this->display();
	 }
	
	function editgg_lbimg(){
        $id = intval($_GET['id']);
		if($id==''){
			$pan_admin=$this->pan_quan(2);//判断权限
			
			$this->assign('pagetitle', '添加其他广告位图片');
		}else{
			$pan_admin=$this->pan_quan(4);//判断权限
			
			 $list = M('gg_lbimg')->find($id);
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改其他广告位图片');
		}
		$wz=M('gg_wz')->where("state=1")->order('xu asc,id asc')->select();
	    $this->assign('wz', $wz);
		$lang=M('pz_lang')->where("state=1")->order('xu asc,id asc')->select();
		foreach($lang as $k=>$v){
			$lang[$k]['menu_name']=$list["name".$v['id'].""];
			$lang[$k]['menu_img']=$list["img".$v['id'].""];
		}
	    $this->assign('lang_name', $lang);
	    $this->assign('lang_img_name', $lang);
	    $this->assign('lang_img', $lang);

		$webs=M('webs')->where("state=1")->order('id asc')->select();
	    $this->assign('webs', $webs);

		$this->display('gg_lbimg_edit');
	}
   
   function dogg_lbimg(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		
		$_POST['uid']=$_SESSION['uid'];
		if($_POST['id']){
			$_POST['stime']=time();
				if( M('gg_lbimg')->save($_POST) ){
					$this->assign('jumpUrl', U('System/gg_lbimg'));
					$this->success('修改成功！');
				}else{
					$this->error('没有任何改动　或　修改失败！');
				}
		}else{
			$_POST['ctime']=time();
		      if( M('gg_lbimg')->add($_POST) ){
					$this->assign('jumpUrl', U('System/gg_lbimg'));
					$this->success('添加成功！');
			  }else{
					$this->error('添加失败！');
			  }
		}
	}

	/**
	 * ------------------------------
	 * 投票 主题 管理
	 * ------------------------------
	 */

	function tou(){
	
		import("@.ORG.Page");
		$count	= M('tou')->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		$list = M('tou')->order('ctime desc,id desc')->limit($Page->firstRow.','.$Page->listRows)
						     ->select();
	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '投票主题列表');
		$this->display();
	 }
	
	function edittou(){
        $id = intval($_GET['id']);
		if($id==''){
			$pan_admin=$this->pan_quan(12);//判断权限
			
			$this->assign('pagetitle', '添加投票主题');
		}else{
			$pan_admin=$this->pan_quan(12);//判断权限
			
			 $list = M('tou')->find($id);
			foreach($list as $k=>$v){
				if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
					$list[$k]=stripslashes($v); 
				}
			}
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改投票主题');
		}
		$lang=M('pz_lang')->where("state=1")->order('xu asc,id asc')->select();
		foreach($lang as $k=>$v){
			$lang[$k]['menu_name']=$list["name".$v['id'].""];
			$lang[$k]['menu_content']=$list["content".$v['id'].""];
		}
	    $this->assign('lang_name', $lang);
	    $this->assign('lang_content', $lang);

		$this->display('tou_edit');
	}
   
   function dotou(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		
		$_POST['uid']=$_SESSION['uid'];
		$_POST['state']=1;
		
		if($_POST['id']){
			$_POST['stime']=time();
			if( M('tou')->save($_POST) ){
				$this->assign('jumpUrl', U('System/tou'));
				$this->success('修改成功！');
			}else{
				$this->error('没有任何改动　或　修改失败！');
			}
		}else{
			$_POST['ctime']=time();
			if( M('tou')->add($_POST) ){
				$this->assign('jumpUrl', U('System/tou'));
				$this->success('添加成功！');
			}else{
				$this->error('添加失败！');
			}
		}
	}

	/**
	 * ------------------------------
	 * 投票 事项 管理
	 * ------------------------------
	 */

	function tou_shi(){
	
		import("@.ORG.Page");
		$count	= M('tou_shi')->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		$list = M('tou_shi')->order('tid desc,ctime asc,id asc')->limit($Page->firstRow.','.$Page->listRows)
						     ->select();
		foreach($list as $k=>$v){
			$tou=M('tou')->find($v['tid']);
			$list[$k]['tou_name']=$tou['name'];
		}
	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '投票事项列表');
		$this->display();
	 }
	
	function edittou_shi(){
        $id = intval($_GET['id']);
		
		$tou=M('tou')->where("state=1")->order('ctime desc,id desc')->select();
		$this->assign('tou', $tou);
		
		if($id==''){
			$pan_admin=$this->pan_quan(12);//判断权限
			
			$this->assign('pagetitle', '添加投票事项');
		}else{
			$pan_admin=$this->pan_quan(12);//判断权限
			
			 $list = M('tou_shi')->find($id);
			foreach($list as $k=>$v){
				if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
					$list[$k]=stripslashes($v); 
				}
			}
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改投票事项');
		}
		$lang=M('pz_lang')->where("state=1")->order('xu asc,id asc')->select();
		foreach($lang as $k=>$v){
			$lang[$k]['menu_name']=$list["name".$v['id'].""];
			$lang[$k]['menu_jianjie']=$list["jianjie".$v['id'].""];
			$lang[$k]['menu_img']=$list["img".$v['id'].""];
		}
	    $this->assign('lang_name', $lang);
	    $this->assign('lang_jianjie', $lang);
	    $this->assign('lang_img', $lang);

		$this->display('tou_shi_edit');
	}
   
   function dotou_shi(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		
		if($_POST['id']){
			$_POST['stime']=time();
			if( M('tou_shi')->save($_POST) ){
				$this->assign('jumpUrl', U('System/tou_shi'));
				$this->success('修改成功！');
			}else{
				$this->error('没有任何改动　或　修改失败！');
			}
		}else{
			$_POST['uid']=$_SESSION['uid'];
			$_POST['state']=1;
			$_POST['ctime']=time();
			if( M('tou_shi')->add($_POST) ){
				$this->assign('jumpUrl', U('System/tou_shi'));
				$this->success('添加成功！');
			}else{
				$this->error('添加失败！');
			}
		}
	}

	/**
	 * ------------------------------
	 * 投票 选项 管理
	 * ------------------------------
	 */

	function tou_xuan(){
	
		import("@.ORG.Page");
		$count	= M('tou_xuan')->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		$list = M('tou_xuan')->order('tid desc,sid desc,ctime asc,id asc')->limit($Page->firstRow.','.$Page->listRows)
						     ->select();
		foreach($list as $k=>$v){
			$tou=M('tou')->find($v['tid']);
			$list[$k]['tou_name']=$tou['name'];
			if($v['sid']==0){
				$list[$k]['tou_shi_name']="该主题下全部";
			}else{
				$tou_shi=M('tou_shi')->find($v['sid']);
				$list[$k]['tou_shi_name']=$tou_shi['name'];
			}
		}
	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '投票选项列表');
		$this->display();
	 }
	
	function edittou_xuan(){
        $id = intval($_GET['id']);
		
		$tou=M('tou')->where("state=1")->order('ctime desc,id desc')->select();
		$this->assign('tou', $tou);
		
		$tous=M('tou_shi')->where("state=1")->order('ctime desc,id desc')->select();
		$this->assign('tous', $tous);
		
		if($id==''){
			$pan_admin=$this->pan_quan(12);//判断权限
			
			$this->assign('pagetitle', '添加投票选项');
		}else{
			$pan_admin=$this->pan_quan(12);//判断权限
			
			 $list = M('tou_xuan')->find($id);
			foreach($list as $k=>$v){
				if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
					$list[$k]=stripslashes($v); 
				}
			}
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改投票选项');
		}
		$lang=M('pz_lang')->where("state=1")->order('xu asc,id asc')->select();
		foreach($lang as $k=>$v){
			$lang[$k]['menu_name']=$list["name".$v['id'].""];
		}
	    $this->assign('lang_name', $lang);

		$this->display('tou_xuan_edit');
	}
   
   function dotou_xuan(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		
		if($_POST['id']){
			$_POST['stime']=time();
			if( M('tou_xuan')->save($_POST) ){
				$this->assign('jumpUrl', U('System/tou_xuan'));
				$this->success('修改成功！');
			}else{
				$this->error('没有任何改动　或　修改失败！');
			}
		}else{
			$_POST['uid']=$_SESSION['uid'];
			$_POST['state']=1;
		
			$_POST['ctime']=time();
			if( M('tou_xuan')->add($_POST) ){
				$this->assign('jumpUrl', U('System/tou_xuan'));
				$this->success('添加成功！');
			}else{
				$this->error('添加失败！');
			}
		}
	}

	/**
	 * ------------------------------
	 * 投票 结果 管理
	 * ------------------------------
	 */

	function tou_jieguo(){
	
		import("@.ORG.Page");
		$count	= M('tou')->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		$list = M('tou')->order('ctime desc,id desc')->limit($Page->firstRow.','.$Page->listRows)
						     ->select();
		foreach($list as $k=>$v){
			$tou_shi=M('tou_shi')->where("tid=".$v['id']."")->order('ctime asc,id asc')->select();
			$list[$k]['toushi']=$tou_shi;
			foreach($list[$k]['toushi'] as $kk=>$vv){
				$tou_xuan_all=M('tou_xuan')->where("tid=".$v['id']." and sid=0")->order('ctime asc,id asc')->select();
				foreach($tou_xuan_all as $t=>$a){
					$num1=M('tou_jieguo')->where("tid=".$v['id']." and sid=".$vv['id']." and xid=".$a['id']."")->count();
					$num2s=M('tou_jieguo')->where("tid=".$v['id']." and sid=".$vv['id']." and xid=".$a['id']." and uid=1")->find();
					$num2=$num2s['jishu'];
					$tou_xuan_all[$t]['num']=$num1+$num2;
				}
				$tou_xuan_dan=M('tou_xuan')->where("tid=".$v['id']." and sid=".$vv['id']."")->order('ctime asc,id asc')->select();
				foreach($tou_xuan_dan as $ts=>$as){
					$num1s=M('tou_jieguo')->where("tid=".$v['id']." and sid=".$vv['id']." and xid=".$as['id']."")->count();
					$num2ss=M('tou_jieguo')->where("tid=".$v['id']." and sid=".$vv['id']." and xid=".$as['id']." and uid=1")->find();
					$num2s=$num2ss['jishu'];
					$tou_xuan_dan[$ts]['num']=$num1s+$num2s;
				}
				$list[$k]['toushi'][$kk]['touxuan_all']=$tou_xuan_all;
				$list[$k]['toushi'][$kk]['touxuan_dan']=$tou_xuan_dan;
				
			}
			
		}

	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '投票结果列表');
		$this->display();
	 }
	
	function edittou_jieguo(){
        $id = intval($_GET['id']);
		
		if($id==''){
		
			$tou=M('tou')->where("state=1")->order('ctime desc,id desc')->select();
			$this->assign('tou', $tou);
			
			$tous=M('tou_shi')->where("state=1")->order('ctime desc,id desc')->select();
			$this->assign('tous', $tous);
			
			$toux=M('tou_xuan')->where("state=1")->order('ctime desc,id desc')->select();
			$this->assign('toux', $toux);
			
			$this->assign('pagetitle', '添加投票结果');
		}else{
			$this->assign('tou_shi_id', $id);
			
			$tou_shi=M('tou_shi')->find($id);
			$this->assign('tou_shi', $tou_shi);
			$tou_xuan_all=M('tou_xuan')->where("sid=".$id." and tid=".$tou_shi['tid']." and state=1")->select();
			$tou_xuan_dan=M('tou_xuan')->where("sid=0 and tid=".$tou_shi['tid']." and state=1")->select();
			$this->assign('tou_xuan_all', $tou_xuan_all);
			$this->assign('tou_xuan_dan', $tou_xuan_dan);

			$this->assign('type', 'edit');
			$this->assign('pagetitle', '修改投票结果');
		}

		$this->display('tou_jieguo_edit');
	}
   
   function dotou_jieguo(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		
		if($_POST['ssid']){
			$ss['ctime']=time();
			$ss['state']=1;
			$ss['tid']=$_POST['stid'];
			$ss['sid']=$_POST['ssid'];
			$ss['xid']=$_POST['sxid'];
			$ss['uid']=$_SESSION['uid'];
			$ss['jishu']=$_POST['jishu'];
			
			$ss_jiu=M("tou_jieguo")->where("tid=".$ss['tid']." and sid=".$ss['sid']." and xid=".$ss['xid']." and uid=".$ss['uid']." and state=1")->find();
			if(empty($ss_jiu)){
				$ss_cheng=M('tou_jieguo')->add($ss);
			}else{
				$ss['id']=$ss_jiu['id'];
				$ss_cheng=M('tou_jieguo')->save($ss);
			}
			
			if( $ss_cheng ){
				$this->assign('jumpUrl', U('System/tou_jieguo'));
				$this->success('修改成功！');
			}else{
				$this->error('没有任何改动　或　修改失败！');
			}
		}else{
			$addtou['ctime']=time();
			$addtou['state']=1;
			$addtou['tid']=$_POST['tid'];
			$addtou['sid']=$_POST['sid'];
			$addtou['xid']=$_POST['xid'];
			$addtou['uid']=$_SESSION['uid'];
			$addtou['jishu']=$_POST['jishu'];
			
			$addtou_jiu=M("tou_jieguo")->where("tid=".$addtou['tid']." and sid=".$addtou['sid']." and xid=".$addtou['xid']." and uid=".$addtou['uid']." and state=1")->find();
			if(empty($addtou_jiu)){
				$addtou_cheng=M('tou_jieguo')->add($addtou);
			}else{
				$addtou['id']=$addtou_jiu['id'];
				$addtou_cheng=M('tou_jieguo')->save($addtou);
			}
			
			if( $addtou_cheng ){
				$this->assign('jumpUrl', U('System/tou_jieguo'));
				$this->success('添加成功！');
			}else{
				$this->error('添加失败！');
			}
		}
	}
	/**
	 * ------------------------------
	 * 投票 参赛人 信息 管理
	 * ------------------------------
	 */

	function tou_shi_info(){
		$tid=$_GET['tid'];
		import("@.ORG.Page");
		$count	= M('tou_shi_info')->where("tid=".$tid."")->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		$list = M('tou_shi_info')->where("tid=".$tid."")->order('ctime asc,id asc')->limit($Page->firstRow.','.$Page->listRows)
						     ->select();
		foreach($list as $k=>$v){
			$tou=M('tou')->find($v['tid']);
			$list[$k]['tou_name']=$tou['name'];
			$admin=M('admin')->find($v['uid']);
			$list[$k]['tel']=$admin['tel'];
		}
	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '参赛人信息列表');
		$this->display();
	 }
	
	function edittou_shi_info(){
        $id = intval($_GET['id']);
		
		$tou=M('tou')->where("state=1")->order('ctime desc,id desc')->select();
		$this->assign('tou', $tou);
		
		if($id==''){
			$pan_admin=$this->pan_quan(12);//判断权限
			
			$this->assign('pagetitle', '添加参赛人信息');
		}else{
			$pan_admin=$this->pan_quan(12);//判断权限
			
			$list = M('tou_shi_info')->find($id);
			foreach($list as $k=>$v){
				if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
					$list[$k]=stripslashes($v); 
				}
			}
			$this->assign($list);
			
			$admin=M('admin')->find($list['uid']);
			$this->assign('admin',$admin);
			$admin_info=M('admin_info')->where("uid=".$list['uid']."")->find();
			$this->assign('admin_info',$admin_info);
			
			$this->assign('type', 'edit');
			$this->assign('pagetitle', '修改参赛人信息');
		}

		$this->display('tou_shi_info_edit');
	}
   
   function dotou_shi_info(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		
		$tid=$_POST['tid'];
		if(!empty($_POST['uid'])){
			$uid=$_POST['uid'];
		}else{
			$uid=$_SESSION['uid'];
		}
		$tou_shi=M('tou_shi')->where("tid=".$tid." and uid=".$uid."")->find();
		if(!empty($tou_shi)){
			$tou_shi['img']=$_POST['fengmian'];
			$tou_shi['name']=$_POST['name'];
			$tou_shi['stime']=time();
			M('tou_shi')->save($tou_shi);
		}else{
			$tou_shi['tid']=$tid;
			$tou_shi['uid']=$uid;
			$tou_shi['state']=1;
			$tou_shi['ctime']=time();
			$tou_shi['name']=$_POST['name'];
			$tou_shi['img']=$_POST['fengmian'];
			M('tou_shi')->add($tou_shi);
		}
			
		if($_POST['id']){
			$_POST['stime']=time();
			
			if( M('tou_shi_info')->save($_POST) ){
				$this->assign('jumpUrl', U('System/tou_shi_info',array('tid'=>$tid)));
				$this->success('修改成功！');
			}else{
				$this->error('没有任何改动　或　修改失败！');
			}
		}else{
			$_POST['uid']=$uid;
			$_POST['state']=1;
			$_POST['ctime']=time();
			if( M('tou_shi_info')->add($_POST) ){
				$this->assign('jumpUrl', U('System/tou_shi_info',array('tid'=>$tid)));
				$this->success('添加成功！');
			}else{
				$this->error('添加失败！');
			}
		}
	}
	//到处投票结果
	function daochutou_jieguo(){
		$tid=$_GET['id'];
		$stadata = M('tou')->field('id,name')->find($tid);

		$tou_shi=M('tou_shi')->field('id,name')->where("tid=".$tid."")->order("ctime asc,id asc")->select();
		$kaa=2;
		
//		$stanum   = count($stadata);
//		$tou_shi_num=count($tou_shi);
//		$tou_xuan_num=0;
		
		/** Include PHPExcel */
		require_once './admin/Lib/ORG/PHPExcel.php';
		// Create new PHPExcel object
		$objPHPExcel = new PHPExcel();
		// Set document properties
		$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
									 ->setLastModifiedBy("Maarten Balliauw")
									 ->setTitle("Office 2007 XLSX Test Document")
									 ->setSubject("Office 2007 XLSX Test Document")
									 ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
									 ->setKeywords("office 2007 openxml php")
									 ->setCategory("Test result file");
		// Add some data
		$objPHPExcel->setActiveSheetIndex(0)
					->setCellValue('A1', '主题ID')
					->setCellValue('B1', '主题名称')
					->setCellValue('C1', '事项ID')
					->setCellValue('D1', '事项名称')
					->setCellValue('E1', '选项名称')
					->setCellValue('F1', '选项票数')
					->setCellValue('G1', '投票用户ID')
					->setCellValue('H1', '投票用户手机')
					->setCellValue('I1', '投票用户昵称')
					->setCellValue('J1', '投票用户邮箱')
					->setCellValue('K1', '投票用户IP')
					->setCellValue('L1', '投票用户组')
					->setCellValue('M1', '投票用户票数')
					->setCellValue('N1', '基数');
		// Miscellaneous glyphs, UTF-8
//		for($i=0; $i<$stanum; $i++) {
//			$j = $i+2;
//			$objPHPExcel->setActiveSheetIndex(0)
//					->setCellValue('A'.$j, $stadata[$i]['id'])
//					->setCellValue('B'.$j, $stadata[$i]['name'])
//					->setCellValue('C'.$j, $stadata[$i]['dianhua'])
//					->setCellValue('D'.$j, $stadata[$i]['fenlei'])
//					->setCellValue('E'.$j, date('Y-m-d H:i:s',$stadata[$i]['time']));
//		}
		foreach($tou_shi as $k=>$v){
			$tou_shi[$k]['tou_xuan_all']=M('tou_xuan')->where("tid=".$tid." and sid=0")->order("tid asc,sid asc,id asc")->select();
//			$tou_xuan_num=count($tou_shi[$k]['tou_xuan_all'])+$tou_xuan_num;
			foreach($tou_shi[$k]['tou_xuan_all'] as $kk=>$vv){
			
				$num1=M('tou_jieguo')->where("tid=".$tid." and sid=".$v['id']." and xid=".$vv['id']." and uid!=1")->count();
				$num2s=M('tou_jieguo')->where("tid=".$tid." and sid=".$v['id']." and xid=".$vv['id']." and uid=1")->find();
				$num2=$num2s['jishu'];
				$tou_shi[$k]['tou_xuan_all'][$kk]['tou_xuan_all_piaoshu']=$num1+$num2;
					
				$tou_shi[$k]['tou_xuan_all'][$kk]['tou_xuan_all_user_ids']=M('tou_jieguo')->distinct(true)->field('uid')->where("tid=".$tid." and sid=".$v['id']." and xid=".$vv['id']." and uid!=1")->order("sid asc,xid asc,id asc")->select();
				$tou_shi[$k]['tou_xuan_all'][$kk]['tou_xuan_all_user_num']=count($tou_shi[$k]['tou_xuan_all'][$kk]['tou_xuan_all_user_ids']);
				if(empty($tou_shi[$k]['tou_xuan_all'][$kk]['tou_xuan_all_user_ids'])){

						$kaa=$kaa+1;

						$objPHPExcel->setActiveSheetIndex(0)
								->setCellValue('A2', $stadata['id'])
								->setCellValue('B2', $stadata['name'])
								->setCellValue('C'.$kaa, $tou_shi[$k]['id'])
								->setCellValue('D'.$kaa, $tou_shi[$k]['name'])
								->setCellValue('E'.$kaa, $tou_shi[$k]['tou_xuan_all'][$kk]['name'])
								->setCellValue('F'.$kaa, $tou_shi[$k]['tou_xuan_all'][$kk]['tou_xuan_all_piaoshu'])
								->setCellValue('N'.$kaa, $num2s['jishu']);
				}else{
					foreach($tou_shi[$k]['tou_xuan_all'][$kk]['tou_xuan_all_user_ids'] as $kkk=>$vvv){
						$tou_shi[$k]['tou_xuan_all'][$kk]['tou_xuan_all_user_ids'][$kkk]['admin']=M("admin")->find($vvv['uid']);
						$tou_shi[$k]['tou_xuan_all'][$kk]['tou_xuan_all_user_ids'][$kkk]['admin']['group']=M("admin_group")->find($tou_shi[$k]['tou_xuan_all'][$kk]['tou_xuan_all_user_ids'][$kkk]['admin']['groupid']);
						$tou_shi[$k]['tou_xuan_all'][$kk]['tou_xuan_all_user_ids'][$kkk]['admin']['piaoshu']=M("tou_jieguo")->where("tid=".$tid." and sid=".$v['id']." and xid=".$vv['id']." and uid=".$vvv['uid']."")->count();
						
						$kaa=$kaa+1;

						$objPHPExcel->setActiveSheetIndex(0)
								->setCellValue('A2', $stadata['id'])
								->setCellValue('B2', $stadata['name'])
								->setCellValue('C'.$kaa, $tou_shi[$k]['id'])
								->setCellValue('D'.$kaa, $tou_shi[$k]['name'])
								->setCellValue('E'.$kaa, $tou_shi[$k]['tou_xuan_all'][$kk]['name'])
								->setCellValue('F'.$kaa, $tou_shi[$k]['tou_xuan_all'][$kk]['tou_xuan_all_piaoshu'])
								->setCellValue('G'.$kaa, $tou_shi[$k]['tou_xuan_all'][$kk]['tou_xuan_all_user_ids'][$kkk]['admin']['id'])
								->setCellValue('H'.$kaa, $tou_shi[$k]['tou_xuan_all'][$kk]['tou_xuan_all_user_ids'][$kkk]['admin']['tel'])
								->setCellValue('I'.$kaa, $tou_shi[$k]['tou_xuan_all'][$kk]['tou_xuan_all_user_ids'][$kkk]['admin']['nicheng'])
								->setCellValue('J'.$kaa, $tou_shi[$k]['tou_xuan_all'][$kk]['tou_xuan_all_user_ids'][$kkk]['admin']['adm_name'])
								->setCellValue('K'.$kaa, $tou_shi[$k]['tou_xuan_all'][$kk]['tou_xuan_all_user_ids'][$kkk]['admin']['ip'])
								->setCellValue('L'.$kaa, $tou_shi[$k]['tou_xuan_all'][$kk]['tou_xuan_all_user_ids'][$kkk]['admin']['group']['name'])
								->setCellValue('M'.$kaa, $tou_shi[$k]['tou_xuan_all'][$kk]['tou_xuan_all_user_ids'][$kkk]['admin']['piaoshu'])
								->setCellValue('N'.$kaa, $num2s['jishu']);
						
					}
				}
			}

			$tou_shi[$k]['tou_xuan_dan']=M('tou_xuan')->where("tid=".$tid." and sid=".$v['id']."")->order("tid asc,sid asc,id asc")->select();
			foreach($tou_shi[$k]['tou_xuan_dan'] as $kk=>$vv){
				$num1=M('tou_jieguo')->where("tid=".$tid." and sid=".$v['id']." and xid=".$vv['id']." and uid!=1")->count();
				$num2s=M('tou_jieguo')->where("tid=".$tid." and sid=".$v['id']." and xid=".$vv['id']." and uid=1")->find();
				$num2=$num2s['jishu'];
				$tou_shi[$k]['tou_xuan_dan'][$kk]['tou_xuan_dan_piaoshu']=$num1+$num2;
				$tou_shi[$k]['tou_xuan_dan'][$kk]['tou_xuan_dan_user_ids']=M('tou_jieguo')->distinct(true)->field('uid')->where("tid=".$tid." and sid=".$v['id']." and xid=".$vv['id']." and uid!=1")->order("sid asc,xid asc,id asc")->select();
				$tou_shi[$k]['tou_xuan_dan'][$kk]['tou_xuan_dan_user_num']=count($tou_shi[$k]['tou_xuan_dan'][$kk]['tou_xuan_dan_user_ids']);
				if(empty($tou_shi[$k]['tou_xuan_dan'][$kk]['tou_xuan_dan_user_ids'])){
						$kaa=$kaa+1;

						$objPHPExcel->setActiveSheetIndex(0)
								->setCellValue('A2', $stadata['id'])
								->setCellValue('B2', $stadata['name'])
								->setCellValue('C'.$kaa, $tou_shi[$k]['id'])
								->setCellValue('D'.$kaa, $tou_shi[$k]['name'])
								->setCellValue('E'.$kaa, $tou_shi[$k]['tou_xuan_all'][$kk]['name'])
								->setCellValue('F'.$kaa, $tou_shi[$k]['tou_xuan_all'][$kk]['tou_xuan_all_piaoshu'])
								->setCellValue('N'.$kaa, $num2s['jishu']);
				}else{
					foreach($tou_shi[$k]['tou_xuan_dan'][$kk]['tou_xuan_dan_user_ids'] as $kkk=>$vvv){
						$tou_shi[$k]['tou_xuan_dan'][$kk]['tou_xuan_dan_user_ids'][$kkk]['admin']=M("admin")->find($vvv['uid']);
						$tou_shi[$k]['tou_xuan_dan'][$kk]['tou_xuan_dan_user_ids'][$kkk]['admin']['group']=M("admin_group")->find($tou_shi[$k]['tou_xuan_all'][$kk]['tou_xuan_all_user_ids'][$kkk]['admin']['groupid']);
						$tou_shi[$k]['tou_xuan_dan'][$kk]['tou_xuan_dan_user_ids'][$kkk]['admin']['piaoshu']=M("tou_jieguo")->where("tid=".$tid." and sid=".$v['id']." and xid=".$vv['id']." and uid=".$vvv['uid']."")->count();
						
						$kaa=$kaa+1;

						$objPHPExcel->setActiveSheetIndex(0)
								->setCellValue('A2', $stadata['id'])
								->setCellValue('B2', $stadata['name'])
								->setCellValue('C'.$kaa, $tou_shi[$k]['id'])
								->setCellValue('D'.$kaa, $tou_shi[$k]['name'])
								->setCellValue('E'.$kaa, $tou_shi[$k]['tou_xuan_all'][$kk]['name'])
								->setCellValue('F'.$kaa, $tou_shi[$k]['tou_xuan_all'][$kk]['tou_xuan_all_piaoshu'])
								->setCellValue('G'.$kaa, $tou_shi[$k]['tou_xuan_all'][$kk]['tou_xuan_all_user_ids'][$kkk]['admin']['id'])
								->setCellValue('H'.$kaa, $tou_shi[$k]['tou_xuan_all'][$kk]['tou_xuan_all_user_ids'][$kkk]['admin']['tel'])
								->setCellValue('I'.$kaa, $tou_shi[$k]['tou_xuan_all'][$kk]['tou_xuan_all_user_ids'][$kkk]['admin']['nicheng'])
								->setCellValue('J'.$kaa, $tou_shi[$k]['tou_xuan_all'][$kk]['tou_xuan_all_user_ids'][$kkk]['admin']['adm_name'])
								->setCellValue('K'.$kaa, $tou_shi[$k]['tou_xuan_all'][$kk]['tou_xuan_all_user_ids'][$kkk]['admin']['ip'])
								->setCellValue('L'.$kaa, $tou_shi[$k]['tou_xuan_all'][$kk]['tou_xuan_all_user_ids'][$kkk]['admin']['group']['name'])
								->setCellValue('M'.$kaa, $tou_shi[$k]['tou_xuan_all'][$kk]['tou_xuan_all_user_ids'][$kkk]['admin']['piaoshu'])
								->setCellValue('N'.$kaa, $num2s['jishu']);
					}
				}
			}
		}
		
//		foreach($tou_shi as $k=>$v){
//			foreach($tou_shi[$k]['tou_xuan_all'] as $kk=>$vv){
//				
//				foreach($tou_shi[$k]['tou_xuan_all'][$kk]['tou_xuan_all_user_ids'] as $kkk=>$vvv){
//					$ks=($k+1)*($kk+1)*($kkk+1);
//					$objPHPExcel->setActiveSheetIndex(0)
//							->setCellValue('A2', $stadata['id'])
//							->setCellValue('B2', $stadata['name'])
//							->setCellValue('C'.$ks, $tou_shi[$k]['id'])
//							->setCellValue('D'.$ks, $tou_shi[$k]['name'])
//							->setCellValue('E'.$ks, $tou_shi[$k]['tou_xuan_all'][$kk]['name'])
//							->setCellValue('F'.$ks, $tou_shi[$k]['tou_xuan_all'][$kk]['tou_xuan_all_piaoshu'])
//							->setCellValue('G'.$ks, $tou_shi[$k]['tou_xuan_all'][$kk]['tou_xuan_all_user_ids'][$kkk]['admin']['id'])
//							->setCellValue('H'.$ks, $tou_shi[$k]['tou_xuan_all'][$kk]['tou_xuan_all_user_ids'][$kkk]['admin']['tel'])
//							->setCellValue('I'.$ks, $tou_shi[$k]['tou_xuan_all'][$kk]['tou_xuan_all_user_ids'][$kkk]['admin']['nicheng'])
//							->setCellValue('J'.$ks, $tou_shi[$k]['tou_xuan_all'][$kk]['tou_xuan_all_user_ids'][$kkk]['admin']['adm_name'])
//							->setCellValue('K'.$ks, $tou_shi[$k]['tou_xuan_all'][$kk]['tou_xuan_all_user_ids'][$kkk]['admin']['ip'])
//							->setCellValue('L'.$ks, $tou_shi[$k]['tou_xuan_all'][$kk]['tou_xuan_all_user_ids'][$kkk]['admin']['group']['name'])
//							->setCellValue('M'.$ks, $tou_shi[$k]['tou_xuan_all'][$kk]['tou_xuan_all_user_ids'][$kkk]['admin']['piaoshu'])
//							->setCellValue('N'.$ks, $tou_shi[$k]['tou_xuan_all'][$kk]['tou_xuan_all_user_ids'][$kkk]['admin']['jishu']);
//					
//				}
//			}
//
//			foreach($tou_shi[$k]['tou_xuan_dan'] as $kk=>$vv){
//				
//				foreach($tou_shi[$k]['tou_xuan_dan'][$kk]['tou_xuan_dan_user_ids'] as $kkk=>$vvv){
//
//				}
//			}
//		}
		//设置单元格宽度
        $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(5);
        $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(10);
        $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(5);
        $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(10);
        $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(10);
        $objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(8);
        $objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(5);
        $objPHPExcel->getActiveSheet()->getColumnDimension('H')->setWidth(15);
        $objPHPExcel->getActiveSheet()->getColumnDimension('I')->setWidth(15);
        $objPHPExcel->getActiveSheet()->getColumnDimension('J')->setWidth(15);
        $objPHPExcel->getActiveSheet()->getColumnDimension('K')->setWidth(10);
        $objPHPExcel->getActiveSheet()->getColumnDimension('L')->setWidth(12);
        $objPHPExcel->getActiveSheet()->getColumnDimension('M')->setWidth(10);
        $objPHPExcel->getActiveSheet()->getColumnDimension('N')->setWidth(8);
		//合并单元格
        $objPHPExcel->getActiveSheet()->mergeCells('A2:A'.$kaa);
        $objPHPExcel->getActiveSheet()->mergeCells('B2:B'.$kaa);
		//设置居中
        $objPHPExcel->getActiveSheet()->getStyle('A1:N'.$kaa)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
		//所有垂直居中
        $objPHPExcel->getActiveSheet()->getStyle('A1:N'.$kaa)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
		//设置自动换行
        $objPHPExcel->getActiveSheet()->getStyle('A1:N'.$kaa)->getAlignment()->setWrapText(true);
		// Rename worksheet
		$objPHPExcel->getActiveSheet()->setTitle('Simple');
		// Set active sheet index to the first sheet, so Excel opens this as the first sheet
		$objPHPExcel->setActiveSheetIndex(0);
		//$user = iconv('utf-8','gb2312',$user);
		// Redirect output to a client’s web browser (Excel5)
		header('Content-Type: application/vnd.ms-excel');
		header('Content-Disposition: attachment;filename='.$stadata['name'].'tou_jieguo'.date('YmdHis',time()).'.xls');
		header('Cache-Control: max-age=0');

		$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
		$objWriter->save('php://output');
		
		exit;

	}



}